package com.zebra.sdl;

import java.util.Locale;

import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.jb.Preference;
import android.jb.barcode.BarcodeManager;
import android.jb.utils.Tools;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.text.InputFilter;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;

import com.main.BaseActivity;
import com.zebra.adc.decoder.BarCodeReader;
import com.zebra.sdl.SdlScanService;
import com.zebra.sdl.SdlScanService.MyBinder;
import com.electrictorch.ElectrictorchActivity;
import com.example.ht380d4G_jar_demo.R;

public class SdlScanSetupActivity extends BaseActivity implements
		OnCheckedChangeListener {
	private static final String TAG = "SdlScanSetupActivity";
	private TextView tv_scan_model_info , tv_uhf_model_info;
	private RadioButton enterRb, semicolonRb, noneRb;
	private CheckBox netPageSupportCb;
	private CheckBox cb_scan_effect_sound, cb_scan_effect_vibration,
			cb_scan_save_txt_support, cb_scan_shortcut_support,cb_uhf_shortcut_support,
			cb_scan_start_open_support, scan_return_factory_cb,cb_phone_scan_open_support;
	private RadioGroup rg_outmode, rg_short_cut, rg_shortcut_mode;
	private RadioButton rd_scan_out_mode_1, rd_scan_out_mode_2,rd_scan_out_mode_3,
			rd_scan_shortcut_1, rd_scan_shortcut_2, rd_scan_shortcut_3,
			rd_shortcut_mode_1, rd_shortcut_mode_2;
	private Spinner spinner_scan_model,spinner_scan_power;
	public BeepManagerSdl mBeepManagersdl;
	private BarcodeManager scanManager;
	private boolean bind = false;
	public boolean beepMode = false; 		// decode beep enable
	private SdlScanService scanService;
	public static final int SuffixModel_Enter = 0;
	public static final int SuffixModel_Semicolon = 1;
	public static final int SuffixModel_None = -1;
	protected static final int SET_SYMBOLOGIES = 0;
	private BarCodeReader bcr = null;
	private Button bt_symbologies;
	
	private Handler mHandler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			// TODO Auto-generated method stub
			super.handleMessage(msg);
		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.act_scan_setup);

		//showLoadinDialog();
		//Intent service = new Intent(this, SdlScanService.class);
		//startService(service);
		//bindService(service, serviceConnection, BIND_AUTO_CREATE);
	}

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		// initData();
		System.out.println("onStart");
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		initView();
		mBeepManagersdl = new BeepManagerSdl(this,
				beepMode,true);	
		Intent service = new Intent(this, SdlScanService.class);
		bindService(service, serviceConnection, BIND_AUTO_CREATE);
		System.out.println("onResume");
	}

	private void initView() {
		// TODO Auto-generated method stub
		
		enterRb = (RadioButton) findViewById(R.id.scan_setup_enter_rb);
		enterRb.setOnCheckedChangeListener(this);
		semicolonRb = (RadioButton) findViewById(R.id.scan_setup_semicolon_rb);
		semicolonRb.setOnCheckedChangeListener(this);
		noneRb = (RadioButton) findViewById(R.id.scan_setup_none_rb);
		noneRb.setOnCheckedChangeListener(this);
		rd_scan_out_mode_1 = (RadioButton) findViewById(R.id.rd_scan_out_mode_1);
		rd_scan_out_mode_2 = (RadioButton) findViewById(R.id.rd_scan_out_mode_2);
		rd_scan_out_mode_3 = (RadioButton) findViewById(R.id.rd_scan_out_mode_3);
		int scan_mode = getScanOutMode();
		switch (scan_mode) {
		case 2:
			rd_scan_out_mode_1.setChecked(false);
			rd_scan_out_mode_2.setChecked(true);
			rd_scan_out_mode_3.setChecked(false);
			break;
		case 3:
			rd_scan_out_mode_1.setChecked(false);
			rd_scan_out_mode_2.setChecked(false);
			rd_scan_out_mode_3.setChecked(true);
			break;
	
		default:
			rd_scan_out_mode_1.setChecked(true);
			rd_scan_out_mode_2.setChecked(false);
			rd_scan_out_mode_3.setChecked(false);
			break;
		}
		
		rg_outmode = (RadioGroup) findViewById(R.id.rg_outmode);
		rg_outmode
				.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

					@Override
					public void onCheckedChanged(RadioGroup group, int checkedId) {
						// TODO Auto-generated method stub
						// int radioButtonId = group.getCheckedRadioButtonId();
						if (checkedId == R.id.rd_scan_out_mode_3) {
							setScanOutMode(3);
						} else if (checkedId == R.id.rd_scan_out_mode_2){
							setScanOutMode(2);
						} else {
							setScanOutMode(1);
						}
					}
				});

		rd_scan_shortcut_1 = (RadioButton) findViewById(R.id.rd_scan_shortcut_1);
		rd_scan_shortcut_2 = (RadioButton) findViewById(R.id.rd_scan_shortcut_2);
		rd_scan_shortcut_3 = (RadioButton) findViewById(R.id.rd_scan_shortcut_3);
		if (getScanShortCutMode().equals("1")) {
			rd_scan_shortcut_3.setChecked(false);
			rd_scan_shortcut_2.setChecked(false);
			rd_scan_shortcut_1.setChecked(true);
		} else if (getScanShortCutMode().equals("3")) {
			rd_scan_shortcut_3.setChecked(true);
			rd_scan_shortcut_2.setChecked(false);
			rd_scan_shortcut_1.setChecked(false);
		} else {
			rd_scan_shortcut_3.setChecked(false);
			rd_scan_shortcut_2.setChecked(true);
			rd_scan_shortcut_1.setChecked(false);
		}
		rg_short_cut = (RadioGroup) findViewById(R.id.rg_short_cut);
		rg_short_cut
				.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

					@Override
					public void onCheckedChanged(RadioGroup group, int checkedId) {
						// TODO Auto-generated method stub
						// int radioButtonId = group.getCheckedRadioButtonId();
						if (checkedId == R.id.rd_scan_shortcut_1) {
							setScanShortCutMode("1");
						} else if (checkedId == R.id.rd_scan_shortcut_3) {
							setScanShortCutMode("3");
						} else {
							setScanShortCutMode("2");
						}
					}
				});

		rd_shortcut_mode_1 = (RadioButton) findViewById(R.id.rd_shortcut_mode_1);
		rd_shortcut_mode_2 = (RadioButton) findViewById(R.id.rd_shortcut_mode_2);
		if (Preference.getScanShortCutPressMode(this) == 2) {
			if(null != scanManager){
				scanManager.setScanTime(10000);
			}
			rd_shortcut_mode_2.setChecked(true);
			rd_shortcut_mode_1.setChecked(false);
		} else {
			if(null != scanManager){
				scanManager.setScanTime(3000);
			}
			rd_shortcut_mode_1.setChecked(true);
			rd_shortcut_mode_2.setChecked(false);
		}
		rg_shortcut_mode = (RadioGroup) findViewById(R.id.rg_shortcut_mode);
		rg_shortcut_mode.setVisibility(View.GONE);
		rg_shortcut_mode
				.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

					@Override
					public void onCheckedChanged(RadioGroup group, int checkedId) {
						// TODO Auto-generated method stub
						// int radioButtonId = group.getCheckedRadioButtonId();
						if (checkedId == R.id.rd_shortcut_mode_1) {
							if(null != scanManager){
								scanManager.setScanTime(3000);
							}
							Preference.setScanShortCutPressMode(SdlScanSetupActivity.this , 1);
						} else {
							if(null != scanManager){
								scanManager.setScanTime(10000);
							}
							Preference.setScanShortCutPressMode(SdlScanSetupActivity.this , 2);
						}
					}
				});
		// if(scanManager.getScanShortcutSupport()){
		// rg_short_cut.setVisibility(View.VISIBLE);
		// }else {
		// rg_short_cut.setVisibility(View.GONE);
		// }

		cb_scan_effect_sound = (CheckBox) findViewById(R.id.cb_scan_effect_sound);
		cb_scan_effect_sound.setChecked(isPlaySound());
		cb_scan_effect_sound
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					@Override
					public void onCheckedChanged(CompoundButton buttonView,
							boolean isChecked) {
						// TODO Auto-generated method stub
						if (mBeepManagersdl!=null) {
							setPlaySound(isChecked);
						}
					}
				});

		cb_scan_effect_vibration = (CheckBox) findViewById(R.id.cb_scan_effect_vibration);
		cb_scan_effect_vibration.setChecked(isVibrate());
		cb_scan_effect_vibration
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					@Override
					public void onCheckedChanged(CompoundButton buttonView,
							boolean isChecked) {
						// TODO Auto-generated method stub					
							setVibrate(isChecked);
					}
				});

		cb_scan_save_txt_support = (CheckBox) findViewById(R.id.cb_scan_save_txt_support);
		cb_scan_save_txt_support.setChecked(getScanSaveTxt());
		cb_scan_save_txt_support
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					@Override
					public void onCheckedChanged(CompoundButton buttonView,
							boolean isChecked) {
						// TODO Auto-generated method stub
						setScanSaveTxt(isChecked);
					}
				});

		cb_scan_shortcut_support = (CheckBox) findViewById(R.id.cb_scan_shortcut_support);
		cb_scan_shortcut_support.setChecked(getScanShortcutSupport());
		cb_scan_shortcut_support
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					@Override
					public void onCheckedChanged(CompoundButton buttonView,
							boolean isChecked) {
						// TODO Auto-generated method stub
						setScanShortcutSupport(isChecked);
						if (isChecked) {
							Log.v(TAG,"cb_scan_shortcut_support isChecked: "+isChecked);
							rg_shortcut_mode.setVisibility(View.GONE);
						} else {
							rg_shortcut_mode.setVisibility(View.GONE);
						}
						// if(isChecked){
						// rg_short_cut.setVisibility(View.VISIBLE);
						// }else {
						// rg_short_cut.setVisibility(View.GONE);
						// }
					}
				});
		
		cb_uhf_shortcut_support = (CheckBox) findViewById(R.id.cb_uhf_shortcut_support);
		cb_uhf_shortcut_support.setVisibility(View.INVISIBLE);
//		cb_uhf_shortcut_support.setChecked(getUhfShortcutSupport());
//		cb_uhf_shortcut_support
//				.setOnCheckedChangeListener(new OnCheckedChangeListener() {
//
//					@Override
//					public void onCheckedChanged(CompoundButton buttonView,
//							boolean isChecked) {
//						// TODO Auto-generated method stub
//						setUhfShortcutSupport(isChecked);
//						if(null != scanService){
//							scanService.setIsUhfShortcutSupport(isChecked);
//						}
//					}
//				});

		scan_return_factory_cb = (CheckBox) findViewById(R.id.scan_return_factory_cb);
		scan_return_factory_cb.setVisibility(View.GONE);
//		scan_return_factory_cb.setChecked(scanManager.getScanIsReturnFactory());
//		scan_return_factory_cb
//				.setOnCheckedChangeListener(new OnCheckedChangeListener() {
//
//					@Override
//					public void onCheckedChanged(CompoundButton buttonView,
//							boolean isChecked) {
//						// TODO Auto-generated method stub
//						showLoadinDialog();
//						Log.v(TAG,"scan_return_factory_cb scanManager: "+scanManager);
//						scanManager.setScanIsReturnFactory(isChecked);
//						// int prefix = scanManager.autoChoiseScanPrefix();
//
//						// scanManager.setScanPrefix();
//						// if (null != scanManager) {
//						// scanManager.initScanProtocol();
//						// }
//						mHandler.postDelayed(closeLodingIcon, 3000);
//					}
//				});

		cb_scan_start_open_support = (CheckBox) findViewById(R.id.cb_scan_start_open_support);
		if(isZh()){
			cb_scan_start_open_support.setFilters(new InputFilter[]{new InputFilter.LengthFilter(7)});  
		} else {
			cb_scan_start_open_support.setFilters(new InputFilter[]{new InputFilter.LengthFilter(12)});  
		}
		 
		cb_scan_start_open_support.setChecked(getScanStartSelf());
		cb_scan_start_open_support
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					@Override
					public void onCheckedChanged(CompoundButton buttonView,
							boolean isChecked) {
						// TODO Auto-generated method stub
						setScanStartSelf(isChecked);
					}
				});
		netPageSupportCb = (CheckBox) findViewById(R.id.scan_setup_net_page_support_cb);
		netPageSupportCb.setChecked(getScanNetSupport());
		netPageSupportCb
				.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					@Override
					public void onCheckedChanged(CompoundButton buttonView,
							boolean isChecked) {
						// TODO Auto-generated method stub
						setScanNetSupport(isChecked);
					}
				});
		int suffixModel = getScanSuffixModel();
		switch (suffixModel) {
		case -1:
			noneRb.setChecked(true);
			break;
		case 0:
			enterRb.setChecked(true);
			break;
		case 1:
			semicolonRb.setChecked(true);
			break;
		default:
			break;
		}

		spinner_scan_model = (Spinner) findViewById(R.id.spinner_scan_model);
		spinner_scan_power = (Spinner) findViewById(R.id.spinner_scan_power);
		ArrayAdapter<String> adpter_power = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, getResources().getStringArray(
				 R.array.scan_power));
		spinner_scan_power.setAdapter(adpter_power);
		Log.v(TAG,"onItemSelected bcr: "+getScanPower());
		spinner_scan_power.setSelection(getScanPower());
		 spinner_scan_power
		 .setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> arg0, View arg1,
					int arg2, long arg3) {
				// TODO Auto-generated method stub
				setScanPower(arg2);
				Log.v(TAG,"onItemSelected bcr: "+bcr+" arg2: "+arg2);
				if(bcr!=null){
					bcr.setParameter(764, arg2);
				}
				
			}
			@Override
			public void onNothingSelected(AdapterView<?> arg0) {
				// TODO Auto-generated method stub
				
			} 
		 });
		
		tv_scan_model_info = (TextView) findViewById(R.id.tv_scan_model_info);
		tv_uhf_model_info = (TextView) findViewById(R.id.tv_uhf_model_info);
		cb_phone_scan_open_support = (CheckBox)findViewById(R.id.cb_phone_scan_open_support);
		Log.v(TAG,"initView getPhoneScanMode373: "+getPhoneScanMode());
		cb_phone_scan_open_support.setChecked(getPhoneScanMode());
		cb_phone_scan_open_support.setOnCheckedChangeListener(new OnCheckedChangeListener(){

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				Log.v(TAG,"initView getPhoneScanMode381: "+getPhoneScanMode()+"isChecked: "+isChecked+" bcr: "+bcr);
				setPhoneScanMode(isChecked);
				if(isChecked) {
				    bcr.setParameter(716, 1);//support phone mode
				}else {
					bcr.setParameter(716, 0);
				}
				Log.v(TAG,"initView getPhoneScanMode383: "+getPhoneScanMode());
			}
		});
		bt_symbologies = (Button)findViewById(R.id.symbologies);
		bt_symbologies.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent();
		        intent.setClass(SdlScanSetupActivity.this, SymbologiesActivity.class);
		        startActivity(intent);
			}
			
		});
	}
	
	private void initData() {
		// ArrayAdapter<String> adpter_model = new ArrayAdapter<String>(this,
		// R.layout.spinner_item, getResources().getStringArray(
		// R.array.Scan_model));
		// spinner_scan_model.setAdapter(adpter_model);
		// spinner_scan_model.setSelection(scanManager.getScannerModel());
		// spinner_scan_model
		// .setOnItemSelectedListener(new OnItemSelectedListener() {
		//
		// @Override
		// public void onItemSelected(AdapterView<?> arg0, View arg1,
		// int arg2, long arg3) {
		// // if (arg2 != 0) {
		// showLoadinDialog();
		// scanManager.setScannerModel(arg2);
		//
		// // int prefix = scanManager.autoChoiseScanPrefix();
		// // scanManager.setScanPrefix(prefix);
		// scanManager.setScanPrefix();
		// if (null != scanManager) {
		// scanManager.initScanProtocol();
		// }
		// mHandler.postDelayed(closeLodingIcon, 3000);
		// Log.i(TAG, "Scan_model:" + arg2);
		// // }
		// }
		//
		// @Override
		// public void onNothingSelected(AdapterView<?> arg0) {
		// // TODO Auto-generated method stub
		//
		// }
		// });

		String text = "";
		if (null != scanManager) {
			text = scanManager.checkScannerModelSetting_380K();
		}
		if(Tools.isEmpty(text)){
			text = scanManager.checkScannerModelSetting_380A();
		}
		if(Tools.isEmpty(text)){
			text= String.valueOf(scanManager.getScannerModel());
		}
		if (Tools.isEmpty(text)) {
			tv_scan_model_info.setText(getResources().getString(
					R.string.scan_model_nofind_info));
		} else {
			if (text.equals("2") || text.equals("3") || text.equals("4")) {
				tv_scan_model_info.setText(getResources().getString(
						R.string.scan_model_two)
						+ "     " + text);
			} else {
				tv_scan_model_info.setText(getResources().getString(
						R.string.scan_model_one)
						+ "     " + text);
			}
		}
		
		int uhf = Tools.checkUHFModelSetting();
		if(uhf == -1){
			tv_uhf_model_info.setText(getResources().getString(R.string.UHF)+getResources().getString(
					R.string.scan_model_nofind_info));
		}else {
			tv_uhf_model_info.setText(getResources().getString(R.string.UHF)+"      "+uhf);
		}
		tv_uhf_model_info.setVisibility(View.INVISIBLE);

	}
	
	private boolean isZh() {
        Locale locale = getResources().getConfiguration().locale;
        String language = locale.getLanguage();
        if (language.endsWith("zh"))
            return true;
        else
            return false;
    }

	protected void onPause(){
		unbindService(serviceConnection);
        super.onPause();
	}
	@Override
	protected void onDestroy() {
		super.onDestroy();
	}

	@Override
	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
		// TODO Auto-generated method stub
		if (isChecked) {
			switch (buttonView.getId()) {
			case R.id.scan_setup_enter_rb:
				setScanSuffixModel(SuffixModel_Enter);
				break;
			case R.id.scan_setup_none_rb:
				setScanSuffixModel(SuffixModel_None);
				break;
			case R.id.scan_setup_semicolon_rb:
				setScanSuffixModel(SuffixModel_Semicolon);
				break;
			default:
				break;
			}
		}
	}

	ServiceConnection serviceConnection = new ServiceConnection() {

		@Override
		public void onServiceDisconnected(ComponentName name) {
			bind = false;
		}

		@Override
		public void onServiceConnected(ComponentName name, IBinder service) {
			bind = true;
			MyBinder myBinder = (MyBinder) service;
			scanService = myBinder.getService();
			bcr = scanService.getBcr();
		}
	};

	private Runnable closeLodingIcon = new Runnable() {

		@Override
		public void run() {
			// TODO Auto-generated method stub
			closeLoadinDialog();
		}
	};

	/**
	 * 设置是否自启动扫描服务
	 * 
	 * @param b
	 *            ture:自启动 false:不自启动
	 */
	public void setScanStartSelf(boolean b) {
		Preference.setScanSelfopenSupport(this, b);
	}

	/**
	 * 是否自启动扫描服务 , 默认自启动
	 * 
	 * @return b ture:自启动 false:不自启动
	 */
	public boolean getScanStartSelf() {
		return Preference.getScanSelfopenSupport(this, true);
	}

	/**
	 * 设置扫描快捷键
	 * 
	 * @param scanShortcutMode
	 *            1:左侧橙色按键 2:中间橙色按键 3:右边橙色按键
	 */
	public void setScanShortCutMode(String scanShortcutMode) {
		System.out.println("setScanShortCutMode:" + scanShortcutMode);
		Preference.setScanShortcutMode(this, scanShortcutMode);
	}

	/**
	 * 获取扫描快捷键 默认为中间橙色按键
	 * 
	 * @param scanShortcutMode
	 *            1:左侧橙色按键 2:中间橙色按键 3:右边橙色按键
	 */
	public String getScanShortCutMode() {
		// System.out.println("getScanShortCutMode:"+Preference.getScanShortcutMode(this,
		// "2"));
		return Preference.getScanShortcutMode(this, "2");
	}

	/**
	 * 是否播放声音
	 * 
	 * @return <code>true</code> 播放 <code>false</code>不播放
	 */
	public boolean isPlaySound() {
		if (null != mBeepManagersdl) {
			return mBeepManagersdl.isPlayBeep();
		}
		return true;
	}

	/**
	 * 设置扫描是否播放声音 isPlaySound <code>true</code> 播放 <code>false</code>不播放
	 */
	public void setPlaySound(boolean isPlaySound) {
		if (null != mBeepManagersdl) {
			mBeepManagersdl.setPlayBeep(isPlaySound);
		}
	}

	/**
	 * 是否震动
	 * 
	 * @return <code>true</code> 播放 <code>false</code>不播放
	 */
	public boolean isVibrate() {
		if (null != mBeepManagersdl) {
			return mBeepManagersdl.isVibrate();
		}
		return false;
	}

	/**
	 * 设置扫描是否震动 isVibrate <code>true</code> 震动 <code>false</code>不震动
	 */
	public void setVibrate(boolean isVibrate) {
		if (null != mBeepManagersdl) {
			mBeepManagersdl.setVibrate(isVibrate);
		}
		// mBeepManager.setVibrate(isVibrate);
	}

	/**
	 * 设置扫描输出模式
	 * 
	 * @param b
	 *        1.快速扫描（文本框） 2.模拟键盘 3.广播
	 */
	public void setScanOutMode(int b) {
		Preference.setScanOutMode(this, b);
	}

	/**
	 * 后台扫描输出模式  默认广播
	 * @param context
	 * @param ScanOutMode 1.快速扫描（文本框） 2.模拟键盘 3.广播
	 */
	public int getScanOutMode() {
		return Preference.getScanOutMode(this);
	}

	/**
	 * 是否支持扫描快捷键 默认支持
	 * 
	 * @return <code>true</code> 支持 <code>false</code>不支持
	 */
	public boolean getScanShortcutSupport() {
		return Preference.getScanShortcutSupport(this, true);
	}

	/**
	 * 设置扫描是否支持扫描快捷键 b <code>true</code> 支持 <code>false</code>不支持
	 */
	public void setScanShortcutSupport(boolean b) {
		Preference.setScanShortcutSupport(this, b);
	}
	
	/**
	 * 是否支持UHF快捷键扫描 默认支持
	 * 
	 * @return <code>true</code> 支持 <code>false</code>不支持
	 */
	public boolean getUhfShortcutSupport() {
		return Preference.getUhfShortcutSupport(this, true);
	}

	/**
	 * 设置扫描是否支持UHF快捷键 b <code>true</code> 支持 <code>false</code>不支持
	 */
	public void setUhfShortcutSupport(boolean b) {
		Preference.setUhfShortcutSupport(this, b);
	}

	/**
	 * 是否支持网页扫描 默认不支持
	 * 
	 * @return <code>true</code> 支持 <code>false</code>不支持
	 */
	public boolean getScanNetSupport() {
		return Preference.getNetPageSupport(this, false);
	}

	/**
	 * 是否支持网页扫描 默认不支持 b <code>true</code> 支持 <code>false</code>不支持
	 */
	public void setScanNetSupport(boolean b) {
		Preference.setNetPageSupport(this, b);
	}

	/**
	 * 支持扫描快捷自定义后缀 默认后缀回车 -1:无后缀 0：回车 1：分号
	 */
	public int getScanSuffixModel() {
		return Preference.getScanSuffixModel(this, SuffixModel_Enter);
	}

	/**
	 * 设置支持扫描快捷自定义后缀 默认后缀回车 i -1:无后缀 0：回车 1：分号
	 */
	public void setScanSuffixModel(int i) {
		Preference.setScanSuffixModel(this, i);
	}

	/**
	 * 是否支持扫描记录保存至TXT文档 默认不支持 <code>true</code> 支持 <code>false</code> 不支持
	 */
	public boolean getScanSaveTxt() {
		return Preference.getScanSaveTxt(this, false);
	}

	/**
	 * 设置是否支持扫描记录保存至TXT文档 <code>true</code> 支持 <code>false</code> 不支持
	 */
	public void setScanSaveTxt(boolean b) {
		Preference.setScanSaveTxt(this, b);
	}
  
	/**
	 * 是否支持移动电话/显示模式 <code>true</code> 支持 <code>false</code> 不支持
	 */
	public boolean getPhoneScanMode() {
		return Preference.getPhoneScanMode(this, false);
	}

	/**
	 * 设置是否支持移动电话/显示模式 <code>true</code> 支持 <code>false</code> 不支持
	 */
	public void setPhoneScanMode(boolean b) {
		Preference.setPhoneScanMode(this, b);
	}
	/**
	 * 获取扫码power 0-10
	 */
	public int getScanPower() {
		return Preference.getScanPower(this, (int)10);
	}

	/**
	 * 设置扫码power 0-10
	 */
	public void setScanPower(int b) {
		Preference.setScanPower(this, b);
	}
}
